import com.khh.entity.User;
import com.khh.helper.MybatisHelp;
import com.khh.mapper.UserMapper;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.junit.Test;

import java.util.List;

/**
 * Created by webrx on 2017-09-04.
 */
public class Demo {

    @Test
    public void b(){
        MybatisHelp mh = new MybatisHelp();
        SqlSessionFactory sf = mh.getSf();
        SqlSession s1 = sf.openSession();
        UserMapper u1 = s1.getMapper(UserMapper.class);
        List<User> a2 = u1.queryAllByZhu();
        System.out.println(a2);
    }

    @Test
    public void a(){
        //二级缓存
        MybatisHelp mh = new MybatisHelp();
        SqlSessionFactory sf = mh.getSf();
        System.out.println(sf);

        //配置
        //1.
        SqlSession s1 = sf.openSession();
        UserMapper u1 = s1.getMapper(UserMapper.class);
        List<User> a1 = u1.queryAll();
        System.out.println(a1);
        s1.commit();

        //2.
        SqlSession s2 = sf.openSession();
        UserMapper u2 = s2.getMapper(UserMapper.class);
        List<User> a2 = u2.queryAll();
        System.out.println(a2);

    }
}
